package Servlet;

import Dao.officeDao;
import bean.Office;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet(urlPatterns = "/SearchOfficeServlet")
public class SearchOfficeServlet extends BaseServlet{
    officeDao dao = new officeDao();

    protected void list(HttpServletRequest req, HttpServletResponse resp) throws Exception {
        List<Office> officeList = dao.queryOffices();
        req.setAttribute("officeList",officeList);
        req.getRequestDispatcher("/orderOffice.jsp").forward(req,resp);

    }
    protected void SearchOffice(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
            String officeName = req.getParameter("officeName");
            Office office = dao.queryOfficeByName(officeName);
            req.setAttribute("office",office);
            req.getRequestDispatcher("/orderOffice.jsp").forward(req,resp);

    }
}
